﻿namespace CachePage
{
    using System;
    using System.Web.UI;
    using System.Web.UI.Adapters;

    public class UpdatePanelAdapter : ControlAdapter
    {
        protected override void OnInit(EventArgs e)
        {
            if (base.Page.PageAdapter is PageStateAdapter)
            {
                PageStateAdapter pageAdapter = (PageStateAdapter) base.Page.PageAdapter;
                if (pageAdapter.IsExtensionsPage && pageAdapter.IsUpdateTriggers)
                {
                    UpdatePanel control = (UpdatePanel) base.Control;
                    if (control.UpdateMode == UpdatePanelUpdateMode.Conditional)
                    {
                        control.ChildrenAsTriggers = false;
                    }
                }
            }
            base.OnInit(e);
        }
    }
}

